<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class mdl_kurikulum extends CI_Model {
	
	function __construct(){
        parent::__construct();
    }
	
	function togrid($data, $count){
		$response->total = $count;
		$response->rows = array();
		if($count>0){
			$i=0;
			foreach($data->result_array() as $row){
				foreach($row as $key => $value){
					$response->rows[$i][$key]=$value;
				}
				$i++;
			}
		}
		return json_encode($response);
	}
	
	function getjenisaspek($kd_subtema){
		# create query
		$this->db->flush_cache();
		$this->db->start_cache();
			//$this->db->select('kd_matakuliah, nama_matakuliah, sks, semester, kd_jenismk, space(0) as id_jadwal, space(0) as nama_dosen');
			$this->db->select('a.*, c.nama_aspek as aa, d.nama_jenisaspek as bb, c.kd_aspek, c.keterangan');
			$this->db->from('tbl_sd_aspek a');
			$this->db->join('tbl_sd_subtema b','b.kd_subtema = a.kd_subtema');
			$this->db->join('tbl_sub_aspek c','c.kd_aspek = a.kd_aspek');
			$this->db->join('tbl_ref_jenisaspek d','d.kd_jenisaspek = a.kd_jenisaspek');
			$this->db->where('a.kd_subtema', $kd_subtema);
			
			//$this->db->group_by('a.kd_jenisaspek');
			//$this->db->order_by('a.nama_jenisaspek' , 'ASC');
			$this->db->order_by('a.kd_jenisaspek' , 'ASC');
		$this->db->stop_cache();
		
		# get count
		$tmp['row_count'] = $this->db->get()->num_rows();
		
		# get data		
		$tmp['row_data'] = $this->db->get();
		
		return $tmp;
		
	}
	
	function get_JenisAspek($kd_subtema){
		$this->db->flush_cache();
		$this->db->select('nama_jenisaspek');
		$this->db->where('kd_subtema', $kd_subtema);
		//$this->db->where('semester !=', 'SP');
		$this->db->from('tbl_sd_aspek');
		$this->db->order_by('kd_jenisaspek', 'DESC');
		
		$r = $this->db->get();
		
	}
}

?>